<?php

namespace app\admin\model\department;

use think\Model;

class Type extends Model
{
    // 自动写入时间戳字段
    protected $autoWriteTimestamp = false;




    /**
     * 获取栏目的所有子节点ID
     * @param int $id 栏目ID
     * @param bool $withself 是否包含自身
     * @return array
     */
    public static function getChildrenIds($id, $withself = false)
    {
        static $tree;
        if (!$tree) {
            $tree = \fast\Tree::instance();
            $tree->init(collection(self::order('id desc')->select())->toArray(), 'pid');
        }
        $childIds = $tree->getChildrenIds($id, $withself);
        return $childIds;
    }

}
